def handle_contour_4(contour, board_w_pix, board_h_pix, edge_thres, dis_img=None):
    '''
    处理预处理后的特征图
    输入：特征图，板长，宽
    输出：识别结果（ok/fail/error），ok的话还要返回上下框，与长宽的误差，是否重分割过，fail的话要返回原因
    '''
    img = contour.copy()

    board_area = board_h_pix * board_w_pix
    res = {"result": None, "boxes": [], "boxes_id": [], "info": "", "cut_edge": [], "cut_edge_id": [],
           "err": [], "err_id": []}
    (_, cnts, _) = cv2.findContours(img.copy(), cv2.RETR_LIST, cv2.CHAIN_APPROX_SIMPLE)
    cnts = sorted(cnts, key=cv2.contourArea, reverse=True)
    start_id = 0
    draw_color = 0
    s1 = 0
    s2 = 0
    s3 = 0
    s4 = 0
    try:
        _, (w1, h1), _ = cv2.minAreaRect(cnts[start_id])
        s1 = w1 * h1
        rate1 = s1 / board_area
        _, (w2, h2), _ = cv2.minAreaRect(cnts[start_id + 1])
        s2 = w2 * h2
        rate2 = s2 / board_area
        _, (w3, h3), _ = cv2.minAreaRect(cnts[start_id + 2])
        s3 = w3 * h3
        rate3 = s3 / board_area
        _, (w4, h4), _ = cv2.minAreaRect(cnts[start_id + 3])
        s4 = w4 * h4
        rate4 = s4 / board_area
    except:
        pass

    try:
        if len(cnts) == 0:
            res["result"] = "fail"
            res["info"] = "no box"
            return res

        # 检测到两个合适的小框
        elif 0.6 * board_area < s1 < 1.6 * board_area and 0.6 * board_area < s2 < 1.6 * board_area and 0.6 * board_area < s3 < 1.6 * board_area and 0.6 * board_area < s4 < 1.6 * board_area:
            res = check_box_4(cnts, board_w_pix, board_h_pix, edge_thres)
            return res
        elif 1.5 * board_area < s1 < 2.2 * board_area:  # and 0.6 * board_area < s2 < 1.6 * board_area and 0.6 * board_area < s3 < 1.6 * board_area:
            box = cv2.minAreaRect(cnts[start_id])
            boxm = np.int0(cv2.boxPoints((box)))
            lt, rt, rb, lb = get_boxm_points(boxm)
            tm = np.add(lt, rt) / 2
            bm = np.add(rb, lb) / 2
            if tm[0] < 2 / 3 * board_w_pix or tm[0] > 4/3*board_w_pix:
                ty = tm[1] + board_h_pix
                tx = tm[0]
                by = bm[1] - board_h_pix
                bx = bm[0]
                cv2.ellipse(img, (int(tx), int(ty - 800)), (1100, 800), 0, 0, 180, draw_color, 3)
                cv2.ellipse(img, (int(bx), int(by + 800)), (1100, 800), 0, 180, 360, draw_color, 3)
            else:
                tm = np.add(lt, lb) / 2
                bm = np.add(rt, rb) / 2
                ty = tm[1]
                tx = tm[0] + board_w_pix
                by = bm[1]
                bx = bm[0] - board_w_pix
                cv2.ellipse(img, (int(tx - 800), int(ty)), (800, 1240), 0, -90, 90, draw_color, 3)
                cv2.ellipse(img, (int(bx + 800), int(by)), (800, 1240), 0, 90, 270, draw_color, 3)
            (_, cnts, _) = cv2.findContours(img.copy(), cv2.RETR_LIST, cv2.CHAIN_APPROX_SIMPLE)
            cnts = sorted(cnts, key=cv2.contourArea, reverse=True)
            image_show("wufeng", img, 0, True)
            try:
                _, (w1, h1), _ = cv2.minAreaRect(cnts[start_id])
                s1 = w1 * h1
                _, (w2, h2), _ = cv2.minAreaRect(cnts[start_id + 1])
                s2 = w2 * h2
                _, (w3, h3), _ = cv2.minAreaRect(cnts[start_id + 2])
                s3 = w3 * h3
                _, (w4, h4), _ = cv2.minAreaRect(cnts[start_id + 3])
                s4 = w4 * h4
            except Exception as e:
                pass
            if 0.6 * board_area < s1 < 1.6 * board_area and 0.6 * board_area < s2 < 1.6 * board_area and 0.6 * board_area < s3 < 1.6 * board_area and 0.6 * board_area < s4 < 1.6 * board_area:
                res = check_box_4(cnts, board_w_pix, board_h_pix, edge_thres)
                return res
        elif 1.5 * board_area < s1 < 2.2 * board_area and 1.5 * board_area < s2 < 2.2 * board_area:
            pass

        res["result"] = "fail"
        res["info"] = "找板失败"
        return res
    except Exception as e:
        res["result"] = "error"
        res["info"] = str(e)
        return res